﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Batsman_Record
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Browse_Click(object sender, EventArgs e)
        {
            var openFile = new OpenFileDialog();
            openFile.ShowDialog();
            filePath.Text = Path.GetDirectoryName(openFile.FileName);
        }

        private void BatsmanStats_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(Path.Combine(filePath.Text, "Batsman_Records")))
            {
                Directory.CreateDirectory(Path.Combine(filePath.Text, "Batsman_Records"));
            }

            if (!Directory.Exists(Path.Combine(filePath.Text, "Bowler_Records")))
            {
                Directory.CreateDirectory(Path.Combine(filePath.Text, "Bowler_Records"));
            }
            var batsmanStats = new BatsmanStats();
            foreach (var file in Directory.EnumerateFiles(filePath.Text))
            {
                batsmanStats.CreateBatsmanStats(file, InningsWise.Checked, PlayerType.Checked);
            }
        }



        
    }
}
